<?php

namespace App\Console\Commands;

use App\Jobs\goods\SeckillReward;
use App\Models\goods\Order;
use App\Models\goods\OrderDetail;
use App\Models\User;
use Illuminate\Console\Command;

class App extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'app {options=start}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'app maintain command';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {

        switch ($this->argument('options')){
            case 'start':
                $this->start();
                break;
            case 'stop':
                $this->stop();
                break;
            default:
                $this->restart();
                break;
        };
    }

    private function start()
    {

        $this->info(exec('php artisan route:cache'));

        $this->info(exec('php artisan config:cache'));

    }

    private function stop()
    {

        $this->info(exec('php artisan config:clear'));

        $this->info(exec('php artisan route:clear'));

        $this->info(exec('php artisan view:clear'));

        $this->info(exec('php artisan cache:clear'));

    }


    private function restart()
    {
        $this->stop();
        $this->start();
    }

}
